/*var a1 = Math.floor(Math.random()*4+1);
var a2 = Math.floor(Math.random()*4+1);
var a3 = Math.floor(Math.random()*4+1);
var a4 = Math.floor(Math.random()*4+1);
var a5 = Math.floor(Math.random()*4+1);
var a6 = Math.floor(Math.random()*4+1);
var a7 = Math.floor(Math.random()*4+1);
var a8 = Math.floor(Math.random()*4+1);
var a9 = Math.floor(Math.random()*4+1);

var status = 0;
var cost = Array(1,10,100,1000,10000,100000,1000000);
var amount = 0;
var lulz = 0;
var win = 0;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("Oh.. byebye");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendYesNo("Do you want to gamble some mesos?\r\nThe jackpot: #r10x your bet!!!#k");
		} else if (status == 1) {
			cm.sendSimple("#b#L1#I want to do try the Slot Machine#l\r\n#L2#I want to do the Lucky Guess#l#k");
		} else if (status == 2) {
			var text = "How much do you want to gamble?";
			for (var i = 0; i < cost.length; i++) {
				text += "\r\n#L" + i + "##b" + cost[i] + "#k mesos";
			}
			cm.sendSimple(text);
			if (selection == 2) status = 5;
		} else if (status == 3) {
			amount = cost[selection];
			cm.sendYesNo("Are you sure you want to gamble #b" + amount + "#k mesos?");
		} else if (status == 4) {
			if (cm.getChar().getMeso() < amount) {
				cm.sendOk("I'm sorry, but you don't have enough mesos");
				cm.dispose();
				return;
			}
			cm.gainMeso(-amount);
			var text2 = "";
			for (var b = 0; b < 3; b++) {
				for (var c = 0; c < 3; c++) {
					lulz++;
					switch(lulz) {
						case 1: 
							text2 += " #i" + (3992001 + a1) + "# |";
							break;
						case 2: 
							text2 += " #i" + (3992001 + a2) + "# |";
							break;
						case 3: 
							text2 += " #i" + (3992001 + a3) + "#\r\n-------------------------\r\n";
							break;
						case 4: 
							text2 += " #i" + (3992001 + a4) + "# |";
							break;
						case 5: 
							text2 += " #i" + (3992001 + a5) + "# |";
							break;
						case 6: 
							text2 += " #i" + (3992001 + a6) + "#\r\n-------------------------\r\n";
							break;
						case 7: 
							text2 += " #i" + (3992001 + a7) + "# |";
							break;
						case 8: 
							text2 += " #i" + (3992001 + a8) + "# |";
							break;
						case 9: 
							text2 += " #i" + (3992001 + a9) + "#";
							break;
						default:
							text2 += "error";
							break;
					}
				}
			}
			if (((a1 == a2) && (a1 == a3)) || ((a1 == a5) && (a1 == a9)) || ((a4 == a5) && (a4 == a6)) || ((a7 == a8) && (a7 == a9)) || ((a7 == a5) && (a7 == a3))) {
				if (((a4 == a5) && (a4 == a6))) {
					text2 += "#rJackpot! Jackpot! JACKPOT!#k";
					win = 2;
				} else {
					text2 += "\r\n\r\nWow, it seems like #ryou have won#k!";
					win = 1;
				}
			} else {
				text2 += "\r\n\r\nSorry, but you #bhaven't won anything#k..";
				win = 0;
			}
			cm.sendNext(text2);
			lulz = 0;
			a1 = Math.floor(Math.random()*4+1);
			a2 = Math.floor(Math.random()*4+1);
			a3 = Math.floor(Math.random()*4+1);
			a4 = Math.floor(Math.random()*4+1);
			a5 = Math.floor(Math.random()*4+1);
			a6 = Math.floor(Math.random()*4+1);
			a7 = Math.floor(Math.random()*4+1);
			a8 = Math.floor(Math.random()*4+1);
			a9 = Math.floor(Math.random()*4+1);
		} else if (status == 5) {
			if (win == 0) {
				cm.sendOk("Better luck next time..\r\nGoodbye and thanks for participating");
				cm.dispose();
			} else if (win == 1) {
				cm.gainMeso(amount * 3);
				cm.sendOk("I just tripled your bet!\r\nThanks for participating, and come back any time!");
				cm.dispose();
			} else {
				cm.gainMeso(amount * 10);
				cm.sendOk("Wow, good job on winning the #rJackpot#k!\r\nI just have multiplied your bet with 10\r\ncome back any time!");
				cm.dispose();
			}
		} else if (status == 6) {
			amount = cost[selection];
			cm.sendNext("Ah the lucky guess, i will present you 10 bags\r\nYou will have to open one to see what you have won");
		} else if (status == 7) {
			if (cm.getChar().getMeso() < amount) {
				cm.sendOk("I'm sorry, but you don't have enough mesos");
				cm.dispose();
				return;
			}
			cm.gainMeso(-amount);
			var text = "";
			for (var a = 0; a < 10; a++) {
				text += "#L" + a + "##v2100016##l";
			}
			cm.sendSimple(text);
		} else if (status == 8) {
			var xyz = Math.floor(Math.random()*11);
			if (selection == xyz) {
				cm.gainMeso(amount * 10);
				cm.sendOk("Wow, good job on winning the #rJackpot#k!\r\nI just have multiplied your bet with 10\r\ncome back any time!");
			} else {
				cm.sendOk("Sorry but there was nothing in that sack\r\nBetter luck next time..\r\nGoodbye and thanks for participating");
			}	
			cm.dispose();
		}
	}
}*/

var status;
var itemz = Array(1012108, 1012109, 1012110, 1012111);
var chosen;
var str;
var dex;
var intt;
var luk;
var boxes;
var lol;

function start() {
	status = -1;
	chosen = 0;
	str = 0;
	dex = 0;
	intt = 0;
	luk = 0;
	boxes = 0;
	lol = 1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("GoodBye");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendYesNo("Hello, I am the item creator\r\nIn order to use me you must have 5 golden boxes\r\nDo you want to create an item?");
		} else if (status == 1) {
			if (cm.itemQuantity(4280000) >= 5) {
				var text = "What item do you wish to create?\r\n";
				for (var i = 0; i < itemz.length; i++) {
					text += ("#L" + i + "##v" + itemz[i] + "##l\r\n");
				}
				cm.sendSimple(text);
				boxes = (cm.itemQuantity(4280000) - 5);
			} else {
				cm.sendOk("You don't have enough boxes");
				cm.dispose();
			}
    		} else if (status == 2) {
			chosen = itemz[selection];
			cm.sendNext("Ah, you have chosen a #v" + chosen + "#\r\nYou have #r" + boxes + "#k boxes left\r\n\r\nThe current item stats are:\r\n#b0 Str\r\n0 Dex\r\n0 Int\r\n0 Luk#k");
		} else if (status == 3) {
			if (boxes > 0 && lol == 1) {
				cm.sendSimple("You have #r" + boxes + "#k boxes left\r\nThe current item stats are:\r\n#b" + str + "#k Str,\r\n#b" + dex + "#k Dex,\r\n#b" + intt + "#k Int,\r\n#b" + luk + "#k Luk\r\n\r\nI want to use 1 Golden box to add#b\r\n\r\n#L1#5 Str#l\r\n#L2#5 Dex#l\r\n#L3#5 Int#l\r\n#L4#5 Luk#l\r\n#L5#Nothing, i'm done creating my item#l#k");
			} else {
				cm.sendYesNo("Do you really want to pay me #r" + (cm.itemQuantity(4280000) - boxes) + "#k boxes?\r\n#v" + chosen + "# would have:\r\n#b" + str + "#k Str,\r\n#b" + dex + "#k Dex,\r\n#b" + intt + "#k Int,\r\n#b" + luk + "#k Luk");
				status++;
			}
		} else if (status == 4) {
			switch (selection) {
				case 1:
					str += 5;
					break;
				case 2:
					dex += 5;
					break;
				case 3:
					intt += 5;
					break;
				case 4:
					luk += 5;
					break;
				default:
					lol = 0;
					status--;
					boxes++;
					break;
			}
			boxes--;
			if (lol == 1 && boxes > 0)
				cm.sendSimple("You have #r" + boxes + "#k boxes left\r\nThe current item stats are:\r\n#b" + str + "#k Str,\r\n#b" + dex + "#k Dex,\r\n#b" + intt + "#k Int,\r\n#b" + luk + "#k Luk\r\n\r\nI want to use 1 Golden box to add#b\r\n\r\n#L1#5 Str#l\r\n#L2#5 Dex#l\r\n#L3#5 Int#l\r\n#L4#5 Luk#l\r\n#L5#Nothing, i'm done creating my item#l#k");
			else {
				cm.sendYesNo("Do you really want to pay me #r" + (cm.itemQuantity(4280000) - boxes) + "#k boxes?\r\n#v" + chosen + "# would have:\r\n#b" + str + "#k Str,\r\n#b" + dex + "#k Dex,\r\n#b" + intt + "#k Int,\r\n#b" + luk + "#k Luk");
				status++;
				status++;
			}
			status--;
			status--;
			status++;
		} else {
			cm.createEquip(chosen, str, dex, intt, luk);
			cm.sendOk("Here you go");
			cm.gainItem(4280000, -(cm.itemQuantity(4280000) - boxes));
			cm.dispose();
		}
	} 
}